﻿@model IEnumerable<MobileSales.Model.Orders.Order>

@{
    View.Title = Strings.Orders;
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>@Strings.Orders</h2>

<p>
    @Html.ActionLink(Strings.CreateNew, "Create", null, new { @class = "icon-button add-icon" })
</p>
<table class="datatable">
    <thead>
    <tr>
        <th style="width:240px;"></th>
        <th>@ModelStrings.Client</th>
        <th>@ModelStrings.Date</th>
        <th>@ModelStrings.OrderStatus</th>
        <th>@Strings.Amount</th>
        <th>@Strings.TotalValue</th>
    </tr>
    </thead>
    <tbody>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.ActionLink(Strings.Edit, "Edit", new { id = item.Id }, new { @class = "icon-button edit-icon" }) |
            @Html.ActionLink(Strings.Details, "Details", new { id = item.Id }, new { @class = "icon-button details-icon" })<br /><br />
            @Html.ActionLink(Strings.Delete, "Delete", new { id = item.Id }, new { @class = "icon-button delete-icon" }) | 
            @Html.ActionLink(Strings.CreateDocument, "Create", "Documents", new { orderId = item.Id }, new { @class = "icon-button document-icon" })
        </td>
        <td>@Html.ClientIdentity(item.ClientId)</td>
        <td>@item.Date.ToShortDateString()</td>
        <td>@item.Status.Name</td>
        <td>@item.Items.Count()</td>
        <td>@String.Format("{0:F}", Html.TotalValueCount(item.Items))</td>
    </tr>
}
</tbody>
</table>

